#-*- coding: utf-8 -*
#@author 小测试
#@create 2020-03-04 13:51

"""
暂时先注释掉
"""
from hashlib import md5
from Crypto.Cipher import AES
import binascii
import base64
def my_md5(msg):
    """
    md5 算法加密
    :param msg: 需加密的字符串
    :return: 加密后的字符
    """
    hl = md5()
    hl.update(msg.encode('utf-8'))
    return hl.hexdigest()
def my_aes_encrypt(msg, key, vi):
    """
    AES 算法的加密
    :param msg: 需加密的字符串
    :param key: 必须为16，24，32位
    :param vi: 必须为16位
    :return: 加密后的字符
    """
    obj = AES.new(key, AES.MODE_CBC, vi)
    txt = obj.encrypt(msg.encode())
    return binascii.b2a_hex(txt).decode()


def my_aes_decrypt(msg, key, vi):
    """
    AES 算法的解密
    :param msg: 需解密的字符串
    :param key: 必须为16，24，32位
    :param vi: 必须为16位
    :return: 加密后的字符
    """
    msg = binascii.a2b_hex(msg)
    obj = AES.new(key, AES.MODE_CBC, vi)
    return obj.decrypt(msg).decode()

def my_base64_encrypt(msg):
    """
    base64的转码
    """
    msg=base64.b64encode(msg.encode("utf-8"))
    return str(msg,"utf-8")

if __name__ == '__main__':
    print(my_base64_encrypt("123456"))
